<template>
    <div class="user">
        <div class="left">
            <div class="breadcrumb">
                <el-breadcrumb separator-class="el-icon-arrow-right">
                    <el-breadcrumb-item :to="{ path: '/' }">
                        <el-icon>
                            <HomeFilled />
                        </el-icon>
                    </el-breadcrumb-item>
                    <el-breadcrumb-item :to="`/user/certification`">会员中心</el-breadcrumb-item>
                    <el-breadcrumb-item :to="{ path: $route.path }">{{ $route.name }}</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
            <div class="menu">
                <el-menu router :default-active="activeIndex" class="el-menu-vertical">
                    <el-menu-item index="/user/certification">
                        <el-icon>
                            <Postcard />
                        </el-icon>
                        <span>实名认证</span>
                    </el-menu-item>
                    <el-menu-item index="/user/order">
                        <el-icon>
                            <Memo />
                        </el-icon>
                        <span>挂号订单</span>
                    </el-menu-item>
                    <el-menu-item index="/user/patient">
                        <el-icon>
                            <User />
                        </el-icon>
                        <span>就诊管理</span>
                    </el-menu-item>
                    <el-menu-item index="/user/profile">
                        <el-icon>
                            <document />
                        </el-icon>
                        <span>账号信息</span>
                    </el-menu-item>
                    <el-menu-item index="/user/feedback">
                        <el-icon>
                            <ChatDotRound />
                        </el-icon>
                        <span>意见反馈</span>
                    </el-menu-item>
                </el-menu>
            </div>
        </div>
        <div class="content">
            <RouterView />
        </div>
    </div>
</template>

<script setup lang="ts">
import {
    Postcard,
    Document,
    HomeFilled,
    ChatDotRound,
    User,
    Memo
} from '@element-plus/icons-vue'
import { computed } from 'vue';
import { useRoute } from 'vue-router';

let $route = useRoute()

let activeIndex = computed(() => {
    if ($route.path === '/user/add' || $route.path === '/user/detail') {
        return '/user/patient';
    }
    return $route.path; // 否则返回当前路径
})
</script>

<style scoped lang="scss">
.user {
    display: flex;

    .breadcrumb {
        padding-bottom: 20px;
    }

    .left {
        flex: 3;
        display: flex;
        flex-direction: column;
        align-items: center;
        position: sticky;
        height: 40vh;
        top: 6.5em;

        .el-menu {
            border: none;
        }
    }

    .content {
        flex: 10;
        margin-top: 50px;
        margin-left: 30px;
    }
}

@media screen and (max-width:800px) {
    .user {
        .left {
            flex: 5;
        }
    }
}
</style>